﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
 using UFIDA.U9.AP.APBill;
 using UFIDA.U9.AP.Payment;
  using UFIDA.U9.Base.MobileApprovalTemplateBP;
using UFIDA.U9.CBO.FI.Enums;
using UFIDA.U9.CBO.FI.Tax;
using UFIDA.U9.CBO.SCM.Customer;
using UFIDA.U9.CBO.SCM.Item;
 using UFIDA.U9.SM.DealerSO;
using UFIDA.U9.SM.Enums;
using UFIDA.U9.SM.Ship;
using UFSoft.UBF.Business;
using UFSoft.UBF.Util.DataAccess;

namespace UFIDA.U9.Cust.LS.PlugBE
{
    public class JHDTO
    {
        public String docno;
        public decimal ProductQty;//已完工数量
        public decimal IssuedQty;// 备料已发放数量
        public decimal sl;// 收率 =已完工数量/备料已发放数量
     }

    public class JHResultDTO
    {
        public String docno;
        public decimal ProductQty;//已完工数量
        public decimal IssuedQty;// 备料已发放数量
        public decimal sl;// 收率 =已完工数量/备料已发放数量
     }



    internal class JHHelper
    {
        /// <summary>
        /// 金汇能收率处理
        /// </summary>
        public static List<JHResultDTO> DDXJH(JHDTO dto)
        {
            List<JHResultDTO> retlist = new List<JHResultDTO>();
            DataSet retds;
            String sql = $"select id, DocNo, ProductQty  ,pk.IssuedQty ,sl from v_cust_mosl_ls where mdbm='{dto.docno}'";
            DataAccessor.RunSQL(DataAccessor.GetConn(), sql, null, out retds);
            if (retds == null || retds.Tables.Count == 0 || retds.Tables[0].Rows.Count == 0)
                throw new Exception($" 生产订单不存在[{dto.docno}]");
            //处理返回值
            retlist.Add(new JHResultDTO()
            {
                docno = dto.docno,
                ProductQty = dto.ProductQty,
                IssuedQty = dto.IssuedQty,
                sl = dto.sl

            }); 
             return retlist;
        }



    }
}
